#include "Contract.h"

ContractListener::ContractListener()
{
}

ContractListener::~ContractListener()
{
	contractList.clear();
}

void ContractListener::BeginContact(b2Contact* contact)
{
	if (contact) {
		ContractInfo ci;
		ci.fixtureA = contact->GetFixtureA();
		ci.fixtureB = contact->GetFixtureB();
		contractList.push_back(ci);
	}

	B2_NOT_USED(contact);
}

void ContractListener::EndContact(b2Contact* contact)
{
	if (contact) {
		
		ContractInfo ci;
		ci.fixtureA = contact->GetFixtureA();
		ci.fixtureB = contact->GetFixtureB();
		
		list<ContractInfo>::iterator pos;
		pos = find(contractList.begin(), contractList.end(), ci);
		if (pos != contractList.end()) {
			contractList.erase(pos);
		}
	}

	B2_NOT_USED(contact);
}

void ContractListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{
	B2_NOT_USED(contact);
	B2_NOT_USED(oldManifold);
}

void ContractListener::PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
{
	B2_NOT_USED(contact);
	B2_NOT_USED(impulse);
}